package com.yuma.springaitool.controller;

import com.yuma.springaitool.service.ToolService;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ToolController {

    @Autowired
    @Qualifier("workChatClient")
    ChatClient workChatClient;

    @Autowired
    ToolService toolService;

    @GetMapping(value = "/tool", produces = "text/stream;charset=UTF8")
    String tool(@RequestParam String message) {
        return workChatClient.prompt().tools(toolService).user(message).call().content();
    }
}
